<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>

    <script>
        const ws = new WebSocket('ws://localhost:8080/ws')
        ws.onopen = function () {
           setInterval(function () {
               ws.send('hello' + Math.random())
           }, 3000)
        }
        ws.onmessage = function (event) {
            console.log(event.data)
        }
        ws.onclose = function () {
            console.log('closed')
        }
    </script>
</div>
</body>
</html>